import { BaseWindow } from "../../../component/window/BaseWindow";
import { ObjCreate } from "../common/ObjCreate";
import { Language } from "../../../../extend/language/Language";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { GTextInput } from "../../../../com/mui/controls/GTextInput";
import { GameConst } from "../../../component/gconst/GameConst";
import { RadioButtonGroup } from "../../../../fl/controls/RadioButtonGroup";
import { EOperOption } from "../../../../Message/Game/EOperOption";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { GButton } from "../../../../com/mui/controls/GButton";
import { GRadioButton } from "../../../../com/mui/controls/GRadioButton";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { QuickBuyWindow } from "../common/QuickBuyWindow";
import { ECategory } from "../../../../Message/Public/ECategory";
import { EProp } from "../../../../Message/Public/EProp";
//class CreateGuildWindow
    
    export  class CreateGuildWindow extends BaseWindow
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public init(): void
        {
            var loc1=0;
            this.setSize(240, 315);
            this.titleHeight = 28;
            loc1 = 16777113;
            ObjCreate.createBg(17, 39, 205, 265, this);
            this.title = Language.getString(57002);
            this._nameText = new GTextFiled();
            this._nameText.text = Language.getString(57003);
            this._nameText.textColor = loc1;
            this._nameText.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._nameText.x = 100;
            this._nameText.y = 40;
            addChild(this._nameText);
            this._nameInput = new GTextInput();
            this._nameInput.maxChars = GameConst.GuildNameLimit;
            this._nameInput.styleName = "GTextInput";
            this._nameInput.width = 195;
            this._nameInput.height = 25;
            this._nameInput.x = 20;
            this._nameInput.y = 65;
            addChild(this._nameInput);
            this._purposeText = new GTextFiled();
            this._purposeText.text = Language.getString(57004);
            this._purposeText.textColor = loc1;
            this._purposeText.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._purposeText.x = 100;
            this._purposeText.y = 93;
            addChild(this._purposeText);
            this._purposeInput = new GTextInput();
            this._purposeInput.maxChars = GameConst.GuildPurposeLimit;
            this._purposeInput.styleName = "GTextInput";
            this._purposeInput.text = Language.getString(57005);
            this._purposeInput.textField.wordWrap = true;
            this._purposeInput.width = 195;
            this._purposeInput.height = 70;
            this._purposeInput.x = 20;
            this._purposeInput.y = 115;
            addChild(this._purposeInput);
            this._radioGroup = new RadioButtonGroup("type");
            this._moneyRadio = ObjCreate.createRadioButton(Language.getStringByParam(57006, GameConst.GuildCreateNeedMoney), 35, 190, 200, 28, this);
            this._moneyRadio.selected = true;
            this._moneyRadio.value = EOperOption.convert(EOperOption._EOperOptionMoney);
            this._moneyRadio.group = this._radioGroup;
            this._propRadio = ObjCreate.createRadioButton(Language.getString(57007), 35, 220, 200, 28, this);
            this._propRadio.value = EOperOption.convert(EOperOption._EOperOptionProp);
            this._propRadio.group = this._radioGroup;
            this._propRadio.selected = true;
            this._buyBtn = ObjCreate.createGButton(Language.getString(57008), 145, 220, 65, 24, this);
            this._buyBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBuyBtnClickHandler);
            this._tipText = ObjCreate.createGTextField(Language.getString(57009), 35, 245, 220, 20, this, GlobalStyle.textFormat2);
            this._tipText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._okBtn = new GButton();
            this._okBtn.label = Language.getString(57010);
            this._okBtn.styleName = "ButtonSpecial";
            this._okBtn.setSize(70, 27);
            this._okBtn.move(80, 270);
            this._okBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onOkBtnClickHandler);
            this.addChild(this._okBtn);
            return;
        }

        /* internal  */onOkBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=this._nameInput.text;
            var loc2=this._purposeInput.text;
            var loc3=(this._radioGroup.selection as GRadioButton).value as EOperOption;
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildCreate, {"option": loc3, "name": loc1, "purpose": loc2}));
            return;
        }

        /* internal  */onBuyBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            QuickBuyWindow.instance.updateWindow(ECategory._ECategoryProp, EProp._EPropGuildCreat);
            QuickBuyWindow.instance.updateDefaultAmount(1);
            QuickBuyWindow.instance.show();
            return;
        }

        /* internal */ /* var */_nameText: GTextFiled;

        /* internal */ /* var */_nameInput: GTextInput;

        /* internal */ /* var */_purposeText: GTextFiled;

        /* internal */ /* var */_purposeInput: GTextInput;

        /* internal */ /* var */_tipText: GTextFiled;

        /* internal */ /* var */_moneyRadio: GRadioButton;

        /* internal */ /* var */_propRadio: GRadioButton;

        /* internal */ /* var */_radioGroup: RadioButtonGroup;

        /* internal */ /* var */_buyBtn: GButton;

        /* internal */ /* var */_okBtn: GButton;
    }
